package com.wude.guild.adapter;

import android.app.Activity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.wude.bean.GiftInfo;
import com.wude.guild.face.GetGiftFace;
import com.wude.guild.holder.GiftHolder;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 唐小妹 on 2017/11/29 0029.
 */

public class ListGiftAdapter extends BaseAdapter {
    private final Activity con;
    public List<GiftInfo> list = new ArrayList<>();
    private GetGiftFace face;

    public ListGiftAdapter(Activity activity, GetGiftFace face) {
        this.con = activity;
        this.face = face;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        GiftHolder holder = null;
        if (view == null) {
            holder = new GiftHolder(face);
        } else {
            holder = (GiftHolder) view.getTag();
        }
        GiftInfo giftInfo = list.get(i);
        holder.setData(giftInfo, i, con);
        return holder.getContentView();
    }


    public void setList(List<GiftInfo> b) {
        this.list = b;
        notifyDataSetChanged();
    }

    public List<GiftInfo> getList() {
        return list;
    }
}
